package com.ruoyi.web.controller.production.blade;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.production.domain.blade.BladeType;
import com.ruoyi.production.service.blade.IBladeTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 刀片类型Controller
 *
 * @author ruoyi
 * @date 2021-07-12
 */
@RestController
@RequestMapping("/production/bladeType")
public class BladeTypeController extends BaseController
{
    @Autowired
    private IBladeTypeService bladeTypeService;

    /**
     * 查询刀片类型列表
     */
    @PreAuthorize("@ss.hasPermi('production:bladeType:list')")
    @GetMapping("/list")
    public TableDataInfo list(BladeType bladeType)
    {
        startPage();
        List<BladeType> list = bladeTypeService.selectBladeTypeList(bladeType);
        return getDataTable(list);
    }

    /**
     * 导出刀片类型列表
     */
    @PreAuthorize("@ss.hasPermi('production:bladeType:export')")
    @Log(title = "刀片类型", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BladeType bladeType)
    {
        List<BladeType> list = bladeTypeService.selectBladeTypeList(bladeType);
        ExcelUtil<BladeType> util = new ExcelUtil<BladeType>(BladeType.class);
        return util.exportExcel(list, "刀片类型数据");
    }

    /**
     * 获取刀片类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('production:bladeType:query')")
    @GetMapping(value = "/{bladeTypeId}")
    public AjaxResult getInfo(@PathVariable("bladeTypeId") Long bladeTypeId)
    {
        return AjaxResult.success(bladeTypeService.selectBladeTypeById(bladeTypeId));
    }

    /**
     * 新增刀片类型
     */
    @PreAuthorize("@ss.hasPermi('production:bladeType:add')")
    @Log(title = "刀片类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BladeType bladeType)
    {
        return toAjax(bladeTypeService.insertBladeType(bladeType));
    }

    /**
     * 修改刀片类型
     */
    @PreAuthorize("@ss.hasPermi('production:bladeType:edit')")
    @Log(title = "刀片类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BladeType bladeType)
    {
        return toAjax(bladeTypeService.updateBladeType(bladeType));
    }

    /**
     * 删除刀片类型
     */
    @PreAuthorize("@ss.hasPermi('production:bladeType:remove')")
    @Log(title = "刀片类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bladeTypeIds}")
    public AjaxResult remove(@PathVariable Long[] bladeTypeIds)
    {
        return toAjax(bladeTypeService.deleteBladeTypeByIds(bladeTypeIds));
    }
}
